package com.cod.spieler;

import javax.microedition.khronos.opengles.GL10;

import android.util.Log;

import com.cod.game.system.Node;
import com.cod.math.FastMath;
import com.cod.render.shapes.Cube;

public class Spieler extends Node {
	protected Cube cube;
	public float x,y,z;
	
	public Spieler() {
		cube = new Cube(0.1f);
	}
	
	public void update() {
		super.update();
	}
	
	public void move(float x2, float y2) {
		float deltaX = x2-x;
		float deltaY = y2-y;
		float distance = FastMath.sqrt(deltaX*deltaX+deltaY*deltaY);
		float angle = 1/FastMath.tan(deltaY/deltaX);	
		x += FastMath.cos(angle) * distance/1000;
		y += FastMath.sin(angle) * distance/1000;
		Log.d("Position X",x2+"");
		Log.d("Position Y",y2+"");
	}
	
	public void draw(GL10 gl) {
		super.draw(gl);
		// Koordinaten-System merken
		gl.glPushMatrix();
		// Bewegen
		gl.glTranslatef(x, y, z);
		gl.glTranslatef(0, -0.1f, 0);
		// zeichnen
		cube.draw(gl);
		// Koordinaten-System wiederherstellen
		gl.glPopMatrix();
	}
}
